package com.ac.input.web.form;

import com.caac.core.web.form.BaseSearchForm;
import com.ac.input.dm.HndInpDefItm;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright AgileCentury 2004</p>
 * <p>Company: AgileCentury</p>
 * @author <a href="mailto:lianzs@tom.com">Lianzs</a>
 * @version 1.0
 */

public class ListSearchForm extends BaseSearchForm {
	private HndInpDefItm dm;
	private String mendId;
	private String colId;
	private String whereStr;
	private String code;
	private String name;
	private String[] colNames;

	public String[] getColNames() {
		return colNames;
	}

	public void setColNames(String[] colNames) {
		this.colNames = colNames;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public HndInpDefItm getDm() {
		return dm;
	}

	public void setDm(HndInpDefItm dm) {
		this.dm = dm;
		String strSql = dm.getListSql().toLowerCase().trim();
		int iPos = strSql.indexOf("from");
		String strTemp =strSql.substring(7, iPos);
		colNames = strTemp.split(",");
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCodeColName() {
		return colNames[0];
	}

	public String getNameColName() {
		return colNames[1];
	}

	public String getColId() {
		return colId;
	}

	public void setColId(String colId) {
		this.colId = colId;
	}

	public String getMendId() {
		return mendId;
	}

	public void setMendId(String mendId) {
		this.mendId = mendId;
	}

	public String getWhereStr() {
        whereStr = "";
        if(code!=null &&!"".equals(code)){
        	whereStr = " AND " +colNames[0]+" like '%"+code+"%'";
        }
        if(name!=null &&!"".equals(name)){
        	whereStr = " AND " +colNames[1]+" like '%"+name+"%'";
        }
        if(!"".equals(whereStr) ){
        	whereStr =" where 1=1 " +whereStr;
        }
		return whereStr;
	}

	public void setWhereStr(String whereStr) {
		this.whereStr = whereStr;
	}
}
